//
//  XKTradeController.m
//  XKJY
//
//  Created by xiaokang100 on 2017/2/11.
//  Copyright © 2017年 xiaokang100. All rights reserved.
//

#import "XKTradeController.h"
#import "XKTradeViewController.h"

@interface XKTradeController ()

@property (nonatomic, strong) XKTradeViewController *tradeVC;
@property (nonatomic, strong) UIView *navigationView;

@end
@implementation XKTradeController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.view addSubview:self.navigationView];
    [self.navigationView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_equalTo(self.view);
        make.height.mas_equalTo(64);
    }];
    
    _tradeVC = [XKTradeViewController new];
    _tradeVC.tableView.frame = CGRectMake(0, 64, Main_Width, Main_Height-49);
    [_tradeVC loadHeaderUserAssetData];
    [self.view addSubview:_tradeVC.tableView];
    [self.tradeVC.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(self.view);
        make.top.mas_equalTo(self.navigationView.mas_bottom);
        make.bottom.mas_equalTo(self.view).offset(-49);
    }];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:YES];
    [[NSNotificationCenter defaultCenter] postNotificationName:@"BeganLoadMarketData" object:nil];
    [_tradeVC loadHeaderUserAssetData];
    
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [[NSNotificationCenter defaultCenter] postNotificationName:@"EndLoadMarketData" object:nil];
}


#pragma mark - NavigationView
- (UIView *)navigationView {
    UIView *topView = [UIView new];
    topView.backgroundColor = kBaseRedColor;
    topView.frame = CGRectMake(0, 0, Main_Width, 64);
    [self.view addSubview:topView];
    
    UILabel *titleLabel = [[UILabel alloc] init];
    titleLabel.text = @"WOS种子市场";
    titleLabel.textColor = [UIColor whiteColor];
    titleLabel.font = [UIFont systemFontOfSize:17];
    [topView addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(topView);
        make.centerY.mas_equalTo(topView).offset(10);
    }];
    return topView;
}


@end
